#!/bin/bash

# 从Vue文件中提取所有message字段
echo "Extracting message fields from Vue files..."
grep -ro "message\.[a-zA-Z0-9]*" /Users/guxuefeng/IdeaProjects/yklx/frontend/src --include="*.vue" | cut -d: -f2 | sort | uniq > /Users/guxuefeng/IdeaProjects/yklx/tmp_vue_messages.txt

# 从国际化配置中提取所有message字段
echo "Extracting message fields from i18n config..."
grep -o "message\.[a-zA-Z0-9]*" /Users/guxuefeng/IdeaProjects/yklx/frontend/src/i18n/index.js | sed 's/,$//' | sort | uniq > /Users/guxuefeng/IdeaProjects/yklx/tmp_i18n_messages.txt

echo "Checking for missing translations..."

# 检查哪些字段在i18n配置中缺失
while read -r msg; do
  if ! grep -Fxq "$msg" /Users/guxuefeng/IdeaProjects/yklx/tmp_i18n_messages.txt; then
    echo "MISSING: $msg"
  fi
done < /Users/guxuefeng/IdeaProjects/yklx/tmp_vue_messages.txt

echo "Done checking missing translations."